import {FileUtil} from "../../../../../static/utils/FileUtil";

const sdk_fn = function(func, ...args) {
  return cefCustomObject.func(...args);
};

const getHost = function() {
  return cefCustomObject.getHost();
};

const minWindow = function() {
  return cefCustomObject.minWindow();
};

const exit = function() {
  return cefCustomObject.exit();
};

const getWxGateHost = function() {
  return cefCustomObject.getWxGateHost();
};

const encryptPwd = function() {
  return cefCustomObject.encryptPwd();
};

const enterMove = function() {
  return cefCustomObject.enterMove();
};

const changeSize = function(a, b) {
  return cefCustomObject.changeSize(a, b);
};

const toggleNormalAndMaxWindow = function() {
  return cefCustomObject.toggleNormalAndMaxWindow();
};

const isHostOnline = function() {
  return window.navigator.onLine
};

const downloadThumb = function() {
  return cefCustomObject.downloadThumb();
};

const getVersionStr = function() {
  return cefCustomObject.getVersionStr();
};

const downloadCoursewareResc = function(data) {
  return cefCustomObject.downloadCoursewareResc(data);
};

const downloadResourceZipList = function(data, d2) {
  return cefCustomObject.downloadResourceZipList(data, d2);
};

const saveResourceDetail = function(p1, p2, p3) {
  const path = require('path')
  let tempPath = path.join(window.$DATADIR, "resc", p2, p1 + ".bsr");
  FileUtil.writeFile(JSON.stringify(p3), tempPath);
  return true;
};

const readBsrInfo = function (metaType, metaId) {
  const path = require('path')
  return FileUtil.readFile(path.join(window.$DATADIR, "resc", metaType, metaId + ".bsr"));
}

const rescContextUrl = function() {
  return 'https://content.kquestions.com/';
};

const getCoursewarePath = function(data) {
  return window.$DATADIR + "html\\resc\\courseware\\" + data + ".pptx";
};

const showNavBall = function(data) {
  return cefCustomObject.showNavBall(data);
};

const playResource = function(...data) {
  return cefCustomObject.playResource(...data);
};

const playResourceStat = function(d1, d2, d3) {
  return cefCustomObject.playResourceStat(d1, d2, d3);
};

const hideNavBall = function() {
  return cefCustomObject.hideNavBall();
};

const selectPPT = function(data) {
  return cefCustomObject.selectPPT(data);
};

const playPPT = function(d1, d2 = true) {
  return cefCustomObject.playPPT(d1, d2);
};

const getLessonPptList = function(d1) {
  // return cefCustomObject.getLessonPptList(d1);
    return "";
};

const selectLocalMp4 = function(d1) {
  return cefCustomObject.selectLocalMp4(d1);
};

const playLocalMp4 = function(d1) {
  return cefCustomObject.playLocalMp4(d1);
};

const getLessonMp4List = function(d1) {
  // return cefCustomObject.getLessonMp4List(d1);
    return "";
};

const exportLocalPPT = function(d1, d2) {
  return cefCustomObject.exportLocalPPT(d1, d2);
};

const exportCourseware = function(d1, d2) {
  return cefCustomObject.exportCourseware(d1, d2);
};

const uploadFileToQiniu = function(d1, d2, d3) {
  return cefCustomObject.uploadFileToQiniu(d1, d2, d3);
};

const downloadUserLessonFile = function(d1) {
  return cefCustomObject.downloadUserLessonFile(d1);
};

const isDownloadingCloudResource = function() {
  return cefCustomObject.isDownloadingCloudResource();
};

const downloadCloudResc = function(d1) {
  return cefCustomObject.downloadCloudResc(d1);
};

const removePPT = function(d1, d2) {
  return cefCustomObject.removePPT(d1, d2);
};

const removeMp4 = function(d1, d2) {
  return cefCustomObject.removeMp4(d1, d2);
};

const downloadAndUpdate = function(d1, isZip, isSilent) {
  if (!isZip) {
    isZip = false;
  }
  if (!isSilent) {
    isSilent = false;
  }
  return cefCustomObject.downloadAndUpdate(d1, isZip, isSilent);
};

const isBookDownloading = function() {
  return cefCustomObject.isBookDownloading();
};

const checkDiskFreeSpace = function(d1) {
  return cefCustomObject.checkDiskFreeSpace(d1);
};

const cancelDownload = function() {
  return cefCustomObject.cancelDownload();
};

const getFileMd5 = function(d1) {
  return cefCustomObject.getFileMd5(d1);
};

const getFileSize = function(d1) {
  return cefCustomObject.getFileSize(d1);
};

const getResources = function() {
  return cefCustomObject.getResources();
};

const exitClass = function() {
  return cefCustomObject.exitClass();
};

const showMainWindow = function() {
  return cefCustomObject.showMainWindow();
};

const showMainWindowTimer = function() {
  return cefCustomObject.showMainWindowTimer();
};

const activeMove = function() {
  return cefCustomObject.active();
};

const exitMove = function() {
  return cefCustomObject.exitMove();
};

const showSinglePage = function(...data) {
  return cefCustomObject.showSinglePage(...data);
};

const setFileName = function(...data) {
  return cefCustomObject.setFileName(...data);
};

const hideNav = function() {
  return cefCustomObject.hideNav();
};

const openUrlByDefaultBrowser = function(...data) {
  return cefCustomObject.openUrlByDefaultBrowser(...data);
};

const getScaleFactor = function() {
  return cefCustomObject.getScaleFactor();
};

const clearDownloadCache = function() {
  return cefCustomObject.clearDownloadCache();
};

export default {
  sdk_fn: sdk_fn,
  getHost: getHost,
  minWindow: minWindow,
  exit: exit,
  getWxGateHost: getWxGateHost,
  encryptPwd: encryptPwd,
  enterMove: enterMove,
  changeSize: changeSize,
  toggleNormalAndMaxWindow: toggleNormalAndMaxWindow,
  isHostOnline: isHostOnline,
  downloadThumb: downloadThumb,
  getVersionStr: getVersionStr,
  downloadCoursewareResc: downloadCoursewareResc,
  downloadResourceZipList: downloadResourceZipList,
  saveResourceDetail: saveResourceDetail,
  readBsrInfo: readBsrInfo,
  rescContextUrl: rescContextUrl,
  getCoursewarePath: getCoursewarePath,
  playPPT: playPPT,
  showNavBall: showNavBall,
  playResource: playResource,
  playResourceStat: playResourceStat,
  hideNavBall: hideNavBall,
  selectPPT: selectPPT,
  getLessonPptList: getLessonPptList,
  selectLocalMp4: selectLocalMp4,
  playLocalMp4: playLocalMp4,
  getLessonMp4List: getLessonMp4List,
  exportLocalPPT: exportLocalPPT,
  exportCourseware: exportCourseware,
  uploadFileToQiniu: uploadFileToQiniu,
  downloadUserLessonFile: downloadUserLessonFile,
  isDownloadingCloudResource: isDownloadingCloudResource,
  downloadCloudResc: downloadCloudResc,
  removePPT: removePPT,
  removeMp4: removeMp4,
  downloadAndUpdate: downloadAndUpdate,
  isBookDownloading: isBookDownloading,
  checkDiskFreeSpace: checkDiskFreeSpace,
  cancelDownload: cancelDownload,
  getFileMd5: getFileMd5,
  getFileSize: getFileSize,
  getResources: getResources,
  exitClass: exitClass,
  showMainWindow: showMainWindow,
  showMainWindowTimer: showMainWindowTimer,
  activeMove: activeMove,
  exitMove: exitMove,
  showSinglePage: showSinglePage,
  setFileName: setFileName,
  hideNav: hideNav,
  openUrlByDefaultBrowser: openUrlByDefaultBrowser,
  getScaleFactor: getScaleFactor,
  clearDownloadCache: clearDownloadCache,
};
